# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://doc.scrapy.org/en/latest/topics/item-pipeline.html
import json

class Moviedy90Pipeline(object):
# 写入json文件中
    def __init__(self):
        self.f = open('content.json', 'w',encoding='utf-8')

    def open_spider(self, spider):
        print('打开')

    def process_item(self, item, spider):
        content = json.dumps(dict(item), ensure_ascii=False) + ',\n'
        self.f.write(content)  #python3
        return item

    def close_spider(self, spider):
        print ("{}:爬虫数据处理完毕!".format(spider.name))
        self.f.close()

